package com.hw.dao;

import com.hw.DBUtils;
import com.hw.entity.Bookread;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class BookRDao extends BaseDao<Bookread> {
    public List<Bookread> fromSelct(String mu){
        List<Bookread>list=new ArrayList<>();
        String sql="select * from  BOOKREAD where account =\'"+mu+"\'";
        try {
            ResultSet set=DBUtils.getResult(sql);
            while (set.next()){
                list.add(creatBR(set.getString(1),set.getString(2)));
            }


        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;

    }
    private Bookread creatBR(String account,String bookname){
        Bookread bookread = new Bookread(account,bookname);
        return bookread;
    }
    public void deletd(String account,String booknaem){

        String sql="DELETE FROM bookread WHERE account = '"+account+"' and book_name='"+booknaem+"'";
        System.out.println("sqk"+sql);
        try {
            DBUtils.setSql(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
